/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package imagetest;

import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
import javax.swing.JPanel;

/**
 *
 * @author Staff
 */
public class BananaPanel extends JPanel {
    private boolean drawBanana = false;
    
    public void toggleBanana() {
        drawBanana = !drawBanana;
        repaint();
    }
    
    public void paint(Graphics g) {
        super.paint(g);
        if(drawBanana == true) {
            try{
                String path = "C:\\Users\\Student\\Desktop\\PINEAPPLE.jpg";
                BufferedImage image = ImageIO.read(new File(path));
                g.drawImage(image, 0, 0, this);
            } catch(Exception e) {
                System.out.println(e);
            }
        }
    }
}
